<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/connopen.asp"-->
<!--#include file="lib/asp-common-lib.asp"-->
<%
'获取提交查询的参数
tx_search=trim(SafeRequest("tx_search",0))
userid=trim(SafeRequest("userid",1))
ksrq=trim(SafeRequest("ksrq",0))
if ksrq<>"" then ksrq=cdate(ksrq)
jsrq=trim(SafeRequest("jsrq",0))
if jsrq<>"" then jsrq=cdate(jsrq)
search_complete=trim(SafeRequest("search_complete",0))
search_cd=trim(SafeRequest("search_cd",0))
search_star=trim(SafeRequest("search_star",0))
search_deleted=trim(SafeRequest("search_deleted",0))

'组合sql查询字符串
'sql="select * from cdfee where true "
sql="select "
if search_count<>0 then sql=sql&" top "&search_count
sql=sql&" * from alltodo where true "

if tx_search<>"" then
    sql=sql&" and (title like '%"&tx_search&"%' or todo like '%"&tx_search&"%' or cd_no like '%"&tx_search&"%')"
end if
if ksrq<>"" and jsrq<>"" then	sql=sql&" and (active_date>=#"&ksrq&"# and active_date<=#"&jsrq&"#)"
if search_complete<>"" then sql=sql&" and complete="&search_complete
if search_cd<>"" then
    if search_cd then sql=sql&" and not isnull(cd)" else sql=sql&" and isnull(cd)"
end if
if userid<>0 then sql=sql&" and userid="&userid
if search_star<>"" then sql=sql&" and star="&search_star
if search_deleted<>"" then sql=sql&" and deleted="&search_deleted


sql=sql&" order by edit_datetime desc"
' response.write sql
'response.end
'执行数据查询
set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
If rs.eof Then
  response.write("没有检索到数据!")
  response.end
End if

'分页控制
If saferequest("page",0)<>"" Then	page=clng(saferequest("page",0)) Else	page=1
pc=saferequest("pc",1)
If pc="" Then pc=25
rs.pagesize=pc
pagesize=rs.pagesize
pagecount=rs.pagecount
'page=clng(request.QueryString("page"))
if Not IsEmpty(page) then '如果page_num已经初始化...
  if Not IsNumeric(page) then '判断page_num值是否为数字
    page=1
  else
    page = clng(page) '接收page_num并化为数字型赋给page_num变量
  end if
  if page > pagecount then '如果接收的页数大于总页数
    rs.AbsolutePage = pagecount '设置当前显示页等于最后页
  elseif page <= 0 then '如果page小于等于0
    page=1
    rs.AbsolutePage = page '设置当前显示页等于第一页
  else
    rs.AbsolutePage = page '如果大于零,显示当前页等于接收的页数
  end if
  page = rs.AbsolutePage
end if
%>
<table id="tb_todolist" class="full">
  <thead>
    <tr>
      <th scope="col"><input type="checkbox" id="checkall"></th>
      <th scope="col">ID</th>
      <th scope="col">任务标题</th>
      <th scope="col">关联报关单</th>
      <th scope="col">任务人</th>
      <th scope="col">提醒日期</th>
      <th scope="col">新建日期</th>
      <th scope="col">最后编辑</th>
      <th scope="col">已完成</th>
      <th scope="col">已删除</th>
    </tr>
  </thead>
  <tbody>
<%
For i=1 To pagesize
    If rs.eof Then Exit for
%>
    <tr <%if rs("star") then response.write("class='highlight'")%>>
      <th class="sub" scope="row"><input type="checkbox" name="checkid" class="checkid" value="<%=rs("id")%>" /></th>
      <th class="sub" scope="row"><%=rs.AbsolutePosition%></th>
      <td><%if session("iID")=rs("userid") and not rs("deleted") then%><a href="#" class="todo_edit"><%=rs("title")%></a><%else%><%=rs("title")%><%end if%></td>
      <td><a href="process.asp?id=<%=rs("cd")%>" target="_blank"><%=rs("cd_no")%></a></td>
      <td><%=rs("fullname")%></td>
      <td><%=rs("active_date")%></td>
      <td><%=FormatTime(rs("create_datetime"),"{Y}-{m}-{d}")%></td>
      <td><%=FormatTime(rs("edit_datetime"),"{Y}-{m}-{d}")%></td>
      <td><%if rs("complete") then response.write("是")%></td>
      <td><%if rs("deleted") then response.write("是")%></td>
    </tr>
<%
    rs.movenext()
next
%>
  </tbody>
</table>
<div>
  <span id="pagebar">
    共查询到&nbsp;<%=rs.RecordCount%>&nbsp;条记录&nbsp;
    <%	If page>1 Then	%>
      [<a href="#" id="1">首页</a>]
      [<a href="#" id="<%=page-1%>">上一页</a>]
    <%
        End If
        If Not (page>=pagecount Or pagecount=0) Then
    %>
      [<a href="#" id="<%=page+1%>">下一页</a>]
      [<a href="#" id="<%=pagecount%>">尾页</a>]
    <%	End If %>
      第 <%=page%> 页 / 共 <%=pagecount%> 页
      转到<input id="page_val" type="text" size="2" maxlength="<%=Int(Log(pagecount))+1%>" value="<%=page%>" />页
      <input id="page_go" class="bt_button" type="button" value="Go" />
  </span>
</div>
<%
rs.close
Set rs=nothing
%>

<!--#include file="lib/connclose.asp"-->

